<template>
  <div class="myTest">
    {{info}}world
    <button type="button" @click="test()">点我</button>
    <el-button  type="success" @click="pushPage">push方式实现页面跳转</el-button>
    <el-button  type="success" @click="replacePage">replace方式实现页面跳转</el-button>
    <el-button  type="success" @click="pushPage01">push方式实现页面跳转并传参数</el-button>
    <el-button  type="success" @click="replacePage01">replace方式实现页面跳转并传参数</el-button>

  <router-link :to="{name:'h',query:{'myInfo':info}}">声明式导航</router-link>
  </div>
</template>

<script>
  /* 按需导入*/
  import {test01,hello} from '../../assets/my.js'
  /* 引入对象*/
  import user from '../../assets/myTest'
  /* 默认导出*/
   export default {
         name:"world",//组件描述
         data(){
            return{
                info:"你好",
            }
         },
         methods:{
              test(){//测试
                  var v = $("button").text();
                 // alert(v)
                  //test01();
                  user.show();
              },
              pushPage(){

                //1 根据路由的path地址跳转
                //this.$router.push("/hello");
                //2 根据路由的name值跳转
                this.$router.push({name:'h'});
              },
              replacePage(){
                //1 根据路由的path地址跳转
                //this.$router.replace("/hello");
                //2 根据路由的name值跳转
                this.$router.repalce({name:'h'});
              },
              pushPage01(){
                this.$router.push({
                                name:'h',
                                query:{
                                    "myInfo":this.info
                                },
                              });
                },

              replacePage01(){
                this.$router.replace({
                                name:'h',
                                query:{
                                    "myInfo":this.info
                                },
                              });
                },

         },
         mounted() {
            console.log("nihao");
         }
   }
</script>

<style>
  @import url("../../assets/css/test.css");
</style>
